<?php

use Illuminate\Database\Seeder;

class RolesPermissionPivotTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
    	$items = [];
    	//获取所有权限编码
    	$permissions = DB::table('permissions')->select('code')->get();

    	//管理员拥有最高权限
    	foreach ($permissions as $permission) {
    		$items[] = [
				'role_code' => 'admin',
				'permission_code' => $permission->code,
			];
		}

		/**
		 * 定义经理权限
		 */
		$audits = [
			'dashboard'
		];

    	foreach ($audits as $audit) {
    		$items[] = [
				'role_code' => 'approver',
				'permission_code' => $audit,
			];
		}

    	DB::table('role_permission_pivot')->insert($items);
    }
}
